﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MapHello.Core
{
    class SystemTask : AsyncTask
    {
        public SystemTask()
            : base()
        {
            this.IsSystem = true;
        }

        public override void Run(object state)
        {
            if (!TaskManagement.IsSystemTaskActive)
            {
                Debug.WriteLine("system task awken at: {0}", DateTime.Now);
                SystemTask task = new SystemTask();
                task.Interval = Constants.SystemTaskInterval;

                Debug.WriteLine("next system task awken at: {0}", DateTime.Now.AddMilliseconds(task.Interval));
                TaskManagement.RunTask(task);
            }
            
        }

        protected override void ProtectedNotifyCompletion()
        {
            Debug.WriteLine("system task completed at: {0}", DateTime.Now);
        }
    }
}
